home *** CD-ROM | disk | FTP | other *** search
- package com.opera;
-
- import java.awt.Button;
- import java.awt.Frame;
- import java.awt.TextArea;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
-
- public class JavaConsole extends Frame implements WindowListener, ActionListener, KeyListener {
- private TextArea output_area = new TextArea();
- private Button but;
-
- public JavaConsole() {
- super("Opera Java console");
- this.add(this.output_area);
- this.but = new Button("Clear");
- this.but.addActionListener(this);
- this.add("South", this.but);
- this.pack();
- this.output_area.setVisible(true);
- this.output_area.setEditable(false);
- this.setSize(300, 250);
- ConsoleOStream var1 = new ConsoleOStream(this.output_area);
- System.setOut(var1);
- System.setErr(var1);
- this.addWindowListener(this);
- this.output_area.addKeyListener(this);
- this.but.addKeyListener(this);
- this.printInfo();
- }
-
- public void keyTyped(KeyEvent var1) {
- }
-
- public void keyPressed(KeyEvent var1) {
- if (var1.getModifiers() == 0) {
- switch (var1.getKeyCode()) {
- case 67:
- this.output_area.setText((String)null);
- this.printInfo();
- case 68:
- case 69:
- case 73:
- case 74:
- case 75:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- default:
- break;
- case 70:
- System.out.print("Running finalization ... ");
- System.runFinalization();
- System.out.println("finished.");
- break;
- case 71:
- System.out.print("Running garbage collection ... ");
- System.gc();
- System.out.println("finished.");
- break;
- case 72:
- this.printHelp();
- break;
- case 76:
- PluginPanel.printClassLoaders();
- break;
- case 77:
- long var2 = Runtime.getRuntime().freeMemory() / 1024L;
- long var4 = Runtime.getRuntime().totalMemory() / 1024L;
- System.out.println("Total memory: " + var4 + "K Free memory: " + var2 + "K");
- break;
- case 88:
- PluginPanel.clearClassLoaderCache();
- }
-
- }
- }
-
- private void printInfo() {
- System.out.println("-- Opera Java Console --\n");
- System.out.println("Java vendor: " + System.getProperty("java.vendor"));
- System.out.println("Java version: " + System.getProperty("java.version"));
- System.out.println("\ntype 'h' for help\n\n--");
- }
-
- private void printHelp() {
- System.out.println("\nCommands:\n----------------------------------------");
- System.out.println("c - clear console");
- System.out.println("f - run finalization");
- System.out.println("g - run garbage collection");
- System.out.println("h - help");
- System.out.println("l - list cached classloaders");
- System.out.println("m - memory usage");
- System.out.println("x - clear classloader cache\n");
- }
-
- public void keyReleased(KeyEvent var1) {
- }
-
- public void windowActivated(WindowEvent var1) {
- }
-
- public void windowClosed(WindowEvent var1) {
- }
-
- public void windowClosing(WindowEvent var1) {
- this.dispose();
- }
-
- public void windowDeactivated(WindowEvent var1) {
- }
-
- public void windowDeiconified(WindowEvent var1) {
- }
-
- public void windowIconified(WindowEvent var1) {
- }
-
- public void windowOpened(WindowEvent var1) {
- }
-
- public void actionPerformed(ActionEvent var1) {
- if (var1.getSource() == this.but) {
- this.output_area.setText((String)null);
- this.printInfo();
- }
-
- }
- }
-